package com.cgbl.cg.view

import android.content.Context
import android.graphics.Color
import com.bigkoo.pickerview.builder.TimePickerBuilder
import com.bigkoo.pickerview.view.TimePickerView
import com.lxj.xpopup.core.BottomPopupView
import com.cgbl.cg.R
import java.util.*

class UpdateBirthdayPop(context: Context) : BottomPopupView(context) {

    private lateinit var pvTime: TimePickerView

    override fun getImplLayoutId(): Int {
        return R.layout.app_pop_update_username
    }

    override fun initPopupContent() {
        initPopupContent()
    }

    override fun onShow() {
        super.onShow()
    }


    private fun initTimePicker() {
        //控制时间范围(如果不设置范围，则使用默认时间1900-2100年，此段代码可注释)
        //因为系统Calendar的月份是从0-11的,所以如果是调用Calendar的set方法来设置时间,月份的范围也要是从0-11
        val selectedDate: Calendar = Calendar.getInstance()
        val startDate: Calendar = Calendar.getInstance()
        startDate.set(2013, 0, 23)
        val endDate: Calendar = Calendar.getInstance()
        endDate.set(2019, 11, 28)
        //时间选择器
        pvTime = TimePickerBuilder(
            context
        ) { date, v -> //选中事件回调
            // 这里回调过来的v,就是show()方法里面所添加的 View 参数，如果show的时候没有添加参数，v则为null
            /*btn_Time.setText(getTime(date));*/
//            val btn: Button = v as Button
//            btn.setText(getTime(date))
        }
            .setLayoutRes(
                R.layout.app_pickerview_birthday
            ) { v ->
//                val tvSubmit = v.findViewById(R.id.tv_finish) as TextView
//                val ivCancel = v.findViewById(R.id.iv_cancel) as ImageView
//                tvSubmit.setOnClickListener {
//                    pvTime.returnData()
//                    /*pvTime.dismiss();*/
//                }
//                ivCancel.setOnClickListener { /*pvTime.dismiss();*/ }
            }
            .setType(booleanArrayOf(true, true, true, false, false, false))
            .setLabel("", "", "", "", "", "") //设置空字符串以隐藏单位提示   hide label
            .setDividerColor(Color.DKGRAY)
            .setContentTextSize(20)
            .setDate(selectedDate)
            .setRangDate(startDate, selectedDate)
            .setOutSideColor(0x00000000)
            .setOutSideCancelable(false)
            .isDialog(true)
            .build()
        pvTime.setKeyBackCancelable(false) //系统返回键监听屏蔽掉
    }

}